package com.mallcloud.mall.app.controller;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.mallcloud.mall.app.api.entity.dto.AppMmParkingPayInfoDTO;
import com.mallcloud.mall.app.service.AppMmParkingService;
import com.mallcloud.mall.common.core.util.R;
import com.mallcloud.mall.mall.api.entity.dto.ParkingPaymentInfo;
import com.mallcloud.mall.mall.api.entity.dto.PayParkingFeeDTO;
import com.mallcloud.mall.mall.api.entity.dto.PlateInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

@Api(tags = "app-美美停车场接口")
@RestController
@AllArgsConstructor
@RequestMapping("/app/mmParking")
public class AppMMParkingController {
    private final AppMmParkingService appMmParkingService;

	/**
	 * 停车信息查询
	 */
	@ApiOperation("2.5.1账单查询/费用查询")
    @GetMapping("/getParkingPaymentInfo")
    public R<ParkingPaymentInfo> getParkingPaymentInfo(@RequestParam String plateNo) {
        return R.ok(appMmParkingService.getParkingPaymentInfo(plateNo));
    }

	/**
	 * 目前只用做订单上报 与 抬杠
	 */
	@ApiOperation("2.5.2停车费支付")
    @PostMapping("/payParkingFee")
    public R<JSONObject> payParkingFee(@RequestBody PayParkingFeeDTO dto) {
        return R.ok(appMmParkingService.payParkingFee(dto));
    }

	/**
	 * 为了不想回滚，把券核销、积分抵扣、订单保存、停车费支付 组合成了一个接口
	 */
	@ApiOperation("券核销、积分抵扣、订单保存、停车费支付的综合接口")
	@PostMapping("/payRecordReporting")
	public R<Boolean> payRecordReporting(@RequestBody AppMmParkingPayInfoDTO dto) {
		return R.ok(appMmParkingService.payRecordReporting(dto));
	}

	/**
	 * 查询停车账单日志
	 */
	@ApiOperation("2.3.2查询缴费记录")
	@GetMapping("/getParkingPaymentList")
	public R<List<PlateInfo>> getParkingPaymentList(@RequestParam String plateNos) {
		return R.ok(appMmParkingService.paymentRecordList(Arrays.asList(plateNos.split(StrUtil.COMMA))));
	}

//    @ApiOperation("2.5.8账单查询接口（支持后付费订单）")
//    @PostMapping("/getBackFeeOrderInfo")
//    public R<List<BackFeeOrderInfo>> getBackFeeOrderInfo(@RequestParam String plateNos) {
//        return R.ok(appMmParkingService.getBackFeeOrderInfo(Arrays.asList(plateNos.split(StrUtil.COMMA))));
//    }
//
//    @Deprecated
//    @ApiOperation("3.2.3缴费记录上报")
//    @PostMapping("/postPayFeeInfo")
//    public R<String> postPayFeeInfo(@RequestBody PayParkingFeeDTO payParkingFeeDto) {
//		appMmParkingService.paymentRecordReporting(payParkingFeeDto);
//        return R.ok();
//    }


}
